#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from types import MethodType

#绑定属性和方法
class Student(object):
    #属性限制
    __slots__ = ('name', 'sex', 'age', 'set_age')
    pass

s1 = Student()
s2 = Student()

# s1绑定属性
s1.name = 'jingks'

# s1绑定方法
def set_age(self, age):
    self.age = age

s1.set_age = MethodType(set_age, s1)
s1.set_age(25)

print(s1.name)
print(s1.age)

# 给类绑定属性方法

#属性
Student.sex = 'boy'

#方法
def print_info(self):
    print(self.sex)

Student.print_info = print_info

s2.print_info()